﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Xml;

namespace Genesis
{
    [Serializable()]
    class Song
    {
        public Song()
        {
        }
        public Song(string title, string artist, string album, string genre, string time, int playcount, string location, DateTime date)
        {
            this.Title = title;
            this.Artist = artist;
            this.Album = album;
            this.Genre = genre;
            this.Time = Convert_Time(Convert.ToInt32(time));
            this.PlayCount = playcount;
            this.Location = Convert_Location(location);
            this.Date = date;
        }

        public string Title
        {
            get { return title;}
            set { title = value; }
        }
        private string title;

        public string Artist
        {
            get { return artist; }
            set { artist = value; }
        }
        private string artist;

        public string Album
        {
            get { return album; }
            set { album = value; }
        }
        private string album;

        public string Genre
        {
            get { return genre; }
            set { genre = value; }
        }
        private string genre;

        public string Time
        {
            get { return time; }
            set { time = value; }
        }
        private string time;

        public int PlayCount
        {
            get { return playcount; }
            set { playcount = value; }
        }
        private int playcount;

        public string Location
        {
            get { return location; }
            set { location = value; }
        }
        private string location;

        public int ID
        {
            get { return id; }
            set { id = value; }
        }
        private int id;

        public DateTime Date
        {
            get { return date; }
            set { date = value; }
        }
        private DateTime date;

        private string Convert_Time(int sec)
        {
            string min;
            string second;

            second = Convert.ToString(sec % 60);
            min = Convert.ToString(RoundDown(sec / 60));

            if (second.Length != 2)
                second = "0" + second;

            return min + ":" + second;
        }
        private double RoundDown(double valueToRound)
        {
            double floorValue = Math.Floor(valueToRound);
            if ((valueToRound - floorValue) > .5)
            {
                return (floorValue + 1);
            }
            else
            {
                return (floorValue);
            }
        }
        private string Convert_Location(string path)
        {
            string tmp = "";
            tmp = path.Substring(17, path.Length - 17);
            tmp = tmp.Replace("/", "\\");
            tmp = tmp.Replace("%20", " ");
            return tmp;
        }
    }
}
